home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / plugin / nsIPluginHost.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  14KB  |  315 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsIPluginHost.idl
  3.  */
  4.  
  5. #ifndef __gen_nsIPluginHost_h__
  6. #define __gen_nsIPluginHost_h__
  7.  
  8.  
  9. #ifndef __gen_nspluginroot_h__
  10. #include "nspluginroot.h"
  11. #endif
  12.  
  13. #ifndef __gen_nsIFactory_h__
  14. #include "nsIFactory.h"
  15. #endif
  16.  
  17. #ifndef __gen_nsIPluginInstanceOwner_h__
  18. #include "nsIPluginInstanceOwner.h"
  19. #endif
  20.  
  21. #ifndef __gen_nsIStreamListener_h__
  22. #include "nsIStreamListener.h"
  23. #endif
  24.  
  25. #ifndef __gen_nsIStringStream_h__
  26. #include "nsIStringStream.h"
  27. #endif
  28.  
  29. /* For IDL files that don't want to include root IDL files. */
  30. #ifndef NS_NO_VTABLE
  31. #define NS_NO_VTABLE
  32. #endif
  33. #include "nsplugindefs.h"
  34. #include "nsString.h"
  35. #include "nsNetUtil.h"
  36. #include "prlink.h"  // for PRLibrary
  37. class nsIPlugin; /* forward declaration */
  38.  
  39. class nsIURI; /* forward declaration */
  40.  
  41. class nsIDOMPlugin; /* forward declaration */
  42.  
  43.  
  44. /* starting interface:    nsIPluginHost */
  45. #define NS_IPLUGINHOST_IID_STR "e740d8c4-fd94-456a-9506-9e044c5da27a"
  46.  
  47. #define NS_IPLUGINHOST_IID \
  48.   {0xe740d8c4, 0xfd94, 0x456a, \
  49.     { 0x95, 0x06, 0x9e, 0x04, 0x4c, 0x5d, 0xa2, 0x7a }}
  50.  
  51. class NS_NO_VTABLE nsIPluginHost : public nsIFactory {
  52.  public: 
  53.  
  54.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPLUGINHOST_IID)
  55.  
  56.   /* void init (); */
  57.   NS_IMETHOD Init(void) = 0;
  58.  
  59.   /* void destroy (); */
  60.   NS_IMETHOD Destroy(void) = 0;
  61.  
  62.   /* void loadPlugins (); */
  63.   NS_IMETHOD LoadPlugins(void) = 0;
  64.  
  65.   /* void getPluginFactory (in string aMimeType, out nsIPlugin aPlugin); */
  66.   NS_IMETHOD GetPluginFactory(const char *aMimeType, nsIPlugin **aPlugin) = 0;
  67.  
  68.   /* void instantiateEmbeddedPlugin (in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner); */
  69.   NS_IMETHOD InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner) = 0;
  70.  
  71.   /* void instantiateFullPagePlugin (in string aMimeType, in nsIURI aURI, in nsIStreamListenerRef aStreamListener, in nsIPluginInstanceOwner aOwner); */
  72.   NS_IMETHOD InstantiateFullPagePlugin(const char *aMimeType, nsIURI *aURI, nsIStreamListener * & aStreamListener, nsIPluginInstanceOwner *aOwner) = 0;
  73.  
  74.   /* void setUpPluginInstance (in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner); */
  75.   NS_IMETHOD SetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner) = 0;
  76.  
  77.   /* void isPluginEnabledForType (in string aMimeType); */
  78.   NS_IMETHOD IsPluginEnabledForType(const char *aMimeType) = 0;
  79.  
  80.   /* void isPluginEnabledForExtension (in string aExtension, in constCharStarRef aMimeType); */
  81.   NS_IMETHOD IsPluginEnabledForExtension(const char *aExtension, const char * & aMimeType) = 0;
  82.  
  83.   /* readonly attribute unsigned long pluginCount; */
  84.   NS_IMETHOD GetPluginCount(PRUint32 *aPluginCount) = 0;
  85.  
  86.   /* [noscript] void getPlugins (in unsigned long aPluginCount, out nsIDOMPlugin aPluginArray); */
  87.   NS_IMETHOD GetPlugins(PRUint32 aPluginCount, nsIDOMPlugin **aPluginArray) = 0;
  88.  
  89.   /* void stopPluginInstance (in nsIPluginInstance aInstance); */
  90.   NS_IMETHOD StopPluginInstance(nsIPluginInstance *aInstance) = 0;
  91.  
  92.   /* void handleBadPlugin (in PRLibraryPtr aLibrary, in nsIPluginInstance instance); */
  93.   NS_IMETHOD HandleBadPlugin(PRLibrary * aLibrary, nsIPluginInstance *instance) = 0;
  94.  
  95. };
  96.  
  97. /* Use this macro when declaring classes that implement this interface. */
  98. #define NS_DECL_NSIPLUGINHOST \
  99.   NS_IMETHOD Init(void); \
  100.   NS_IMETHOD Destroy(void); \
  101.   NS_IMETHOD LoadPlugins(void); \
  102.   NS_IMETHOD GetPluginFactory(const char *aMimeType, nsIPlugin **aPlugin); \
  103.   NS_IMETHOD InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner); \
  104.   NS_IMETHOD InstantiateFullPagePlugin(const char *aMimeType, nsIURI *aURI, nsIStreamListener * & aStreamListener, nsIPluginInstanceOwner *aOwner); \
  105.   NS_IMETHOD SetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner); \
  106.   NS_IMETHOD IsPluginEnabledForType(const char *aMimeType); \
  107.   NS_IMETHOD IsPluginEnabledForExtension(const char *aExtension, const char * & aMimeType); \
  108.   NS_IMETHOD GetPluginCount(PRUint32 *aPluginCount); \
  109.   NS_IMETHOD GetPlugins(PRUint32 aPluginCount, nsIDOMPlugin **aPluginArray); \
  110.   NS_IMETHOD StopPluginInstance(nsIPluginInstance *aInstance); \
  111.   NS_IMETHOD HandleBadPlugin(PRLibrary * aLibrary, nsIPluginInstance *instance); 
  112.  
  113. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  114. #define NS_FORWARD_NSIPLUGINHOST(_to) \
  115.   NS_IMETHOD Init(void) { return _to Init(); } \
  116.   NS_IMETHOD Destroy(void) { return _to Destroy(); } \
  117.   NS_IMETHOD LoadPlugins(void) { return _to LoadPlugins(); } \
  118.   NS_IMETHOD GetPluginFactory(const char *aMimeType, nsIPlugin **aPlugin) { return _to GetPluginFactory(aMimeType, aPlugin); } \
  119.   NS_IMETHOD InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner) { return _to InstantiateEmbeddedPlugin(aMimeType, aURL, aOwner); } \
  120.   NS_IMETHOD InstantiateFullPagePlugin(const char *aMimeType, nsIURI *aURI, nsIStreamListener * & aStreamListener, nsIPluginInstanceOwner *aOwner) { return _to InstantiateFullPagePlugin(aMimeType, aURI, aStreamListener, aOwner); } \
  121.   NS_IMETHOD SetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner) { return _to SetUpPluginInstance(aMimeType, aURL, aOwner); } \
  122.   NS_IMETHOD IsPluginEnabledForType(const char *aMimeType) { return _to IsPluginEnabledForType(aMimeType); } \
  123.   NS_IMETHOD IsPluginEnabledForExtension(const char *aExtension, const char * & aMimeType) { return _to IsPluginEnabledForExtension(aExtension, aMimeType); } \
  124.   NS_IMETHOD GetPluginCount(PRUint32 *aPluginCount) { return _to GetPluginCount(aPluginCount); } \
  125.   NS_IMETHOD GetPlugins(PRUint32 aPluginCount, nsIDOMPlugin **aPluginArray) { return _to GetPlugins(aPluginCount, aPluginArray); } \
  126.   NS_IMETHOD StopPluginInstance(nsIPluginInstance *aInstance) { return _to StopPluginInstance(aInstance); } \
  127.   NS_IMETHOD HandleBadPlugin(PRLibrary * aLibrary, nsIPluginInstance *instance) { return _to HandleBadPlugin(aLibrary, instance); } 
  128.  
  129. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  130. #define NS_FORWARD_SAFE_NSIPLUGINHOST(_to) \
  131.   NS_IMETHOD Init(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Init(); } \
  132.   NS_IMETHOD Destroy(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Destroy(); } \
  133.   NS_IMETHOD LoadPlugins(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->LoadPlugins(); } \
  134.   NS_IMETHOD GetPluginFactory(const char *aMimeType, nsIPlugin **aPlugin) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPluginFactory(aMimeType, aPlugin); } \
  135.   NS_IMETHOD InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner) { return !_to ? NS_ERROR_NULL_POINTER : _to->InstantiateEmbeddedPlugin(aMimeType, aURL, aOwner); } \
  136.   NS_IMETHOD InstantiateFullPagePlugin(const char *aMimeType, nsIURI *aURI, nsIStreamListener * & aStreamListener, nsIPluginInstanceOwner *aOwner) { return !_to ? NS_ERROR_NULL_POINTER : _to->InstantiateFullPagePlugin(aMimeType, aURI, aStreamListener, aOwner); } \
  137.   NS_IMETHOD SetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetUpPluginInstance(aMimeType, aURL, aOwner); } \
  138.   NS_IMETHOD IsPluginEnabledForType(const char *aMimeType) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsPluginEnabledForType(aMimeType); } \
  139.   NS_IMETHOD IsPluginEnabledForExtension(const char *aExtension, const char * & aMimeType) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsPluginEnabledForExtension(aExtension, aMimeType); } \
  140.   NS_IMETHOD GetPluginCount(PRUint32 *aPluginCount) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPluginCount(aPluginCount); } \
  141.   NS_IMETHOD GetPlugins(PRUint32 aPluginCount, nsIDOMPlugin **aPluginArray) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPlugins(aPluginCount, aPluginArray); } \
  142.   NS_IMETHOD StopPluginInstance(nsIPluginInstance *aInstance) { return !_to ? NS_ERROR_NULL_POINTER : _to->StopPluginInstance(aInstance); } \
  143.   NS_IMETHOD HandleBadPlugin(PRLibrary * aLibrary, nsIPluginInstance *instance) { return !_to ? NS_ERROR_NULL_POINTER : _to->HandleBadPlugin(aLibrary, instance); } 
  144.  
  145. #if 0
  146. /* Use the code below as a template for the implementation class for this interface. */
  147.  
  148. /* Header file */
  149. class nsPluginHost : public nsIPluginHost
  150. {
  151. public:
  152.   NS_DECL_ISUPPORTS
  153.   NS_DECL_NSIPLUGINHOST
  154.  
  155.   nsPluginHost();
  156.  
  157. private:
  158.   ~nsPluginHost();
  159.  
  160. protected:
  161.   /* additional members */
  162. };
  163.  
  164. /* Implementation file */
  165. NS_IMPL_ISUPPORTS1(nsPluginHost, nsIPluginHost)
  166.  
  167. nsPluginHost::nsPluginHost()
  168. {
  169.   /* member initializers and constructor code */
  170. }
  171.  
  172. nsPluginHost::~nsPluginHost()
  173. {
  174.   /* destructor code */
  175. }
  176.  
  177. /* void init (); */
  178. NS_IMETHODIMP nsPluginHost::Init()
  179. {
  180.     return NS_ERROR_NOT_IMPLEMENTED;
  181. }
  182.  
  183. /* void destroy (); */
  184. NS_IMETHODIMP nsPluginHost::Destroy()
  185. {
  186.     return NS_ERROR_NOT_IMPLEMENTED;
  187. }
  188.  
  189. /* void loadPlugins (); */
  190. NS_IMETHODIMP nsPluginHost::LoadPlugins()
  191. {
  192.     return NS_ERROR_NOT_IMPLEMENTED;
  193. }
  194.  
  195. /* void getPluginFactory (in string aMimeType, out nsIPlugin aPlugin); */
  196. NS_IMETHODIMP nsPluginHost::GetPluginFactory(const char *aMimeType, nsIPlugin **aPlugin)
  197. {
  198.     return NS_ERROR_NOT_IMPLEMENTED;
  199. }
  200.  
  201. /* void instantiateEmbeddedPlugin (in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner); */
  202. NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner)
  203. {
  204.     return NS_ERROR_NOT_IMPLEMENTED;
  205. }
  206.  
  207. /* void instantiateFullPagePlugin (in string aMimeType, in nsIURI aURI, in nsIStreamListenerRef aStreamListener, in nsIPluginInstanceOwner aOwner); */
  208. NS_IMETHODIMP nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType, nsIURI *aURI, nsIStreamListener * & aStreamListener, nsIPluginInstanceOwner *aOwner)
  209. {
  210.     return NS_ERROR_NOT_IMPLEMENTED;
  211. }
  212.  
  213. /* void setUpPluginInstance (in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner); */
  214. NS_IMETHODIMP nsPluginHost::SetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner)
  215. {
  216.     return NS_ERROR_NOT_IMPLEMENTED;
  217. }
  218.  
  219. /* void isPluginEnabledForType (in string aMimeType); */
  220. NS_IMETHODIMP nsPluginHost::IsPluginEnabledForType(const char *aMimeType)
  221. {
  222.     return NS_ERROR_NOT_IMPLEMENTED;
  223. }
  224.  
  225. /* void isPluginEnabledForExtension (in string aExtension, in constCharStarRef aMimeType); */
  226. NS_IMETHODIMP nsPluginHost::IsPluginEnabledForExtension(const char *aExtension, const char * & aMimeType)
  227. {
  228.     return NS_ERROR_NOT_IMPLEMENTED;
  229. }
  230.  
  231. /* readonly attribute unsigned long pluginCount; */
  232. NS_IMETHODIMP nsPluginHost::GetPluginCount(PRUint32 *aPluginCount)
  233. {
  234.     return NS_ERROR_NOT_IMPLEMENTED;
  235. }
  236.  
  237. /* [noscript] void getPlugins (in unsigned long aPluginCount, out nsIDOMPlugin aPluginArray); */
  238. NS_IMETHODIMP nsPluginHost::GetPlugins(PRUint32 aPluginCount, nsIDOMPlugin **aPluginArray)
  239. {
  240.     return NS_ERROR_NOT_IMPLEMENTED;
  241. }
  242.  
  243. /* void stopPluginInstance (in nsIPluginInstance aInstance); */
  244. NS_IMETHODIMP nsPluginHost::StopPluginInstance(nsIPluginInstance *aInstance)
  245. {
  246.     return NS_ERROR_NOT_IMPLEMENTED;
  247. }
  248.  
  249. /* void handleBadPlugin (in PRLibraryPtr aLibrary, in nsIPluginInstance instance); */
  250. NS_IMETHODIMP nsPluginHost::HandleBadPlugin(PRLibrary * aLibrary, nsIPluginInstance *instance)
  251. {
  252.     return NS_ERROR_NOT_IMPLEMENTED;
  253. }
  254.  
  255. /* End of implementation class template. */
  256. #endif
  257.  
  258. /**
  259.  * Used for creating the correct input stream for plugins
  260.  * We can either have raw data (with or without \r\n\r\n) or a path to a file (but it must be native!)
  261.  * When making an nsIInputStream stream for the plugins POST data, be sure to take into 
  262.  * account that it could be binary and full of nulls, see bug 105417. Also, we need 
  263.  * to make a copy of the buffer because the plugin may have allocated it on the stack.
  264.  * For an example of this, see Shockwave registration or bug 108966
  265.  * We malloc only for headers here, buffer for data itself is malloced by ParsePostBufferToFixHeaders()
  266.  */
  267. inline nsresult
  268. NS_NewPluginPostDataStream(nsIInputStream **result,
  269.                            const char *data,
  270.                            PRUint32 contentLength,
  271.                            PRBool isFile = PR_FALSE,
  272.                            PRBool headers = PR_FALSE)
  273. {
  274.   nsresult rv = NS_ERROR_UNEXPECTED;
  275.   if (!data)
  276.     return rv;
  277.   if (!isFile) { // do raw data case first
  278.     if (contentLength < 1)
  279.       return rv;
  280.     
  281.     char *buf = (char*) data;
  282.     if (headers) {
  283.       // in assumption we got correctly formated headers just passed in
  284.       if (!(buf = (char*)nsMemory::Alloc(contentLength)))
  285.         return NS_ERROR_OUT_OF_MEMORY;
  286.       memcpy(buf, data, contentLength);
  287.     }
  288.     nsCOMPtr<nsIStringInputStream> sis = do_CreateInstance("@mozilla.org/io/string-input-stream;1",&rv);
  289.     if (NS_SUCCEEDED(rv)) {
  290.       sis->AdoptData(buf, contentLength);  // let the string stream manage our data
  291.       rv = CallQueryInterface(sis, result);
  292.     }
  293.     else if (headers)
  294.       nsMemory::Free(buf); // Cleanup the memory if the data was copied.
  295.   } else {
  296.     nsCOMPtr<nsILocalFile> file; // tmp file will be deleted on release of stream
  297.     nsCOMPtr<nsIInputStream> fileStream;
  298.     if (NS_SUCCEEDED(rv = NS_NewNativeLocalFile(nsDependentCString(data), PR_FALSE, getter_AddRefs(file))) &&
  299.         NS_SUCCEEDED(rv = NS_NewLocalFileInputStream(getter_AddRefs(fileStream),
  300.                                      file,
  301.                                      PR_RDONLY,
  302.                                      0600,
  303.                                      nsIFileInputStream::DELETE_ON_CLOSE |
  304.                                      nsIFileInputStream::CLOSE_ON_EOF))
  305.                                      ) 
  306.     {
  307.       // wrap the file stream with a buffered input stream
  308.       return NS_NewBufferedInputStream(result, fileStream, 8192);
  309.     }
  310.   }
  311.   return rv;
  312. }
  313.  
  314. #endif /* __gen_nsIPluginHost_h__ */
  315.